package chaw.android.train.MoreActivities;

import chaw.android.train.MoreActivity;
import chaw.android.train.R;
import chaw.android.train.TrainTravelActivity;
import chaw.android.util.Preferences;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.ImageView;

public class MoreConfigActivity extends Activity {
	private ImageView btnBack;
	private CheckBox btnConfigNewChat, btnConfigNewStory, btnConfigFixDisplay;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.more_config);
		
		btnBack = (ImageView) findViewById(R.id.btnBack);
		btnConfigNewStory = (CheckBox) findViewById(R.id.btnConfigNewStory);
		btnConfigNewChat = (CheckBox) findViewById(R.id.btnConfigNewChat);
		btnConfigFixDisplay = (CheckBox) findViewById(R.id.btnConfigFixDisplay);
		
		btnBack.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				MoreActivity parentActivity = (MoreActivity) getParent();
				parentActivity.finishFromChild(MoreConfigActivity.this);
			}
		});
		
		btnConfigNewStory.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Preferences.setBoolean(getBaseContext(), "configNewStory", btnConfigNewStory.isChecked()); 
			}
		});
		
		btnConfigNewChat.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Preferences.setBoolean(getBaseContext(), "configNewChat", btnConfigNewChat.isChecked()); 
			}
		});
		
		btnConfigFixDisplay.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Preferences.setBoolean(getBaseContext(), "configFixDisplay", btnConfigFixDisplay.isChecked()); 
			}
		});
	}
	
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		btnConfigNewChat.setChecked(Preferences.getBoolean(getBaseContext(), "configNewChat"));
		btnConfigNewStory.setChecked(Preferences.getBoolean(getBaseContext(), "configNewStory"));
		btnConfigFixDisplay.setChecked(Preferences.getBoolean(getBaseContext(), "configFixDisplay"));
		for(int i = 0 ; i < 5; i++)
        	TrainTravelActivity.tabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.bg_nav1);
	}
}
